package com.cencat.order.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单查询VO
 * @author cencat
 * @description 固定商家场景多租户SaaS企业综合管理系统订单查询VO
 * @since 2024-01-01
 */
@Data
@Accessors(chain = true)
@Schema(name = "OrderQueryVO", description = "订单查询VO")
public class OrderQueryVO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "订单ID")
    private Long id;

    @Schema(description = "订单编号")
    @Size(max = 64, message = "订单编号长度不能超过64个字符")
    private String orderNo;

    @Schema(description = "商家ID")
    private Long merchantId;

    @Schema(description = "商家名称")
    @Size(max = 200, message = "商家名称长度不能超过200个字符")
    private String merchantName;

    @Schema(description = "用户ID")
    private Long userId;

    @Schema(description = "用户姓名")
    @Size(max = 100, message = "用户姓名长度不能超过100个字符")
    private String userName;

    @Schema(description = "用户手机号")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "用户手机号格式不正确")
    private String userPhone;

    @Schema(description = "收货人姓名")
    @Size(max = 100, message = "收货人姓名长度不能超过100个字符")
    private String receiverName;

    @Schema(description = "收货人手机号")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "收货人手机号格式不正确")
    private String receiverPhone;

    @Schema(description = "订单状态：PENDING_PAYMENT-待支付，PAID-已支付，SHIPPED-已发货，DELIVERED-已送达，COMPLETED-已完成，CANCELLED-已取消，REFUNDING-退款中，REFUNDED-已退款")
    @Pattern(regexp = "^(PENDING_PAYMENT|PAID|SHIPPED|DELIVERED|COMPLETED|CANCELLED|REFUNDING|REFUNDED)$", message = "订单状态不正确")
    private String status;

    @Schema(description = "订单状态")
    private String orderStatus;

    @Schema(description = "订单状态列表")
    private String[] statusList;

    @Schema(description = "支付状态：UNPAID-未支付，PAID-已支付，REFUNDED-已退款")
    @Pattern(regexp = "^(UNPAID|PAID|REFUNDED)$", message = "支付状态不正确")
    private String paymentStatus;

    @Schema(description = "配送状态：PENDING-待发货，SHIPPED-已发货，DELIVERED-已送达")
    @Pattern(regexp = "^(PENDING|SHIPPED|DELIVERED)$", message = "配送状态不正确")
    private String shippingStatus;

    @Schema(description = "退款状态：NO_REFUND-未退款，PARTIAL_REFUND-部分退款，FULL_REFUND-全额退款")
    @Pattern(regexp = "^(NO_REFUND|PARTIAL_REFUND|FULL_REFUND)$", message = "退款状态不正确")
    private String refundStatus;

    @Schema(description = "订单类型：NORMAL-普通订单，PRESALE-预售订单，GROUP_BUY-团购订单")
    @Pattern(regexp = "^(NORMAL|PRESALE|GROUP_BUY)$", message = "订单类型不正确")
    private String orderType;

    @Schema(description = "订单来源：WEB-网页，APP-手机应用，MINI_PROGRAM-小程序，H5-手机网页")
    @Pattern(regexp = "^(WEB|APP|MINI_PROGRAM|H5)$", message = "订单来源不正确")
    private String orderSource;

    @Schema(description = "支付方式：ALIPAY-支付宝，WECHAT-微信支付，BANK_CARD-银行卡，CASH-现金")
    @Pattern(regexp = "^(ALIPAY|WECHAT|BANK_CARD|CASH)$", message = "支付方式不正确")
    private String paymentMethod;

    @Schema(description = "配送方式：EXPRESS-快递配送，SELF_PICKUP-自提")
    @Pattern(regexp = "^(EXPRESS|SELF_PICKUP)$", message = "配送方式不正确")
    private String shippingMethod;

    @Schema(description = "最小订单金额")
    private BigDecimal minTotalAmount;

    @Schema(description = "最大订单金额")
    private BigDecimal maxTotalAmount;

    @Schema(description = "最小金额")
    private BigDecimal minAmount;

    @Schema(description = "最大金额")
    private BigDecimal maxAmount;

    @Schema(description = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @Schema(description = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    @Schema(description = "最小实付金额")
    private BigDecimal minPaidAmount;

    @Schema(description = "最大实付金额")
    private BigDecimal maxPaidAmount;

    @Schema(description = "创建开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createStartTime;

    @Schema(description = "创建结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createEndTime;

    @Schema(description = "支付开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime paidStartTime;

    @Schema(description = "支付结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime paidEndTime;

    @Schema(description = "发货开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime shippedStartTime;

    @Schema(description = "发货结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime shippedEndTime;

    @Schema(description = "完成开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime completedStartTime;

    @Schema(description = "完成结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime completedEndTime;

    @Schema(description = "收货地址省份")
    @Size(max = 50, message = "收货地址省份长度不能超过50个字符")
    private String receiverProvince;

    @Schema(description = "收货地址城市")
    @Size(max = 50, message = "收货地址城市长度不能超过50个字符")
    private String receiverCity;

    @Schema(description = "收货地址区县")
    @Size(max = 50, message = "收货地址区县长度不能超过50个字符")
    private String receiverDistrict;

    @Schema(description = "物流公司")
    @Size(max = 100, message = "物流公司长度不能超过100个字符")
    private String shippingCompany;

    @Schema(description = "物流单号")
    @Size(max = 100, message = "物流单号长度不能超过100个字符")
    private String shippingNo;

    @Schema(description = "支付流水号")
    @Size(max = 100, message = "支付流水号长度不能超过100个字符")
    private String paymentNo;

    @Schema(description = "优惠券编码")
    @Size(max = 64, message = "优惠券编码长度不能超过64个字符")
    private String couponCode;

    @Schema(description = "是否需要发票：0-不需要，1-需要")
    private Integer needInvoice;

    @Schema(description = "发票类型：PERSONAL-个人，COMPANY-企业")
    @Pattern(regexp = "^(PERSONAL|COMPANY)$", message = "发票类型不正确")
    private String invoiceType;

    @Schema(description = "发票抬头")
    @Size(max = 200, message = "发票抬头长度不能超过200个字符")
    private String invoiceTitle;

    @Schema(description = "产品名称（模糊查询）")
    @Size(max = 200, message = "产品名称长度不能超过200个字符")
    private String productName;

    @Schema(description = "产品编码")
    @Size(max = 64, message = "产品编码长度不能超过64个字符")
    private String productCode;

    @Schema(description = "产品分类ID")
    private Long categoryId;

    @Schema(description = "产品品牌ID")
    private Long brandId;

    @Schema(description = "关键词（订单编号、用户姓名、手机号、收货人姓名、收货人手机号）")
    @Size(max = 100, message = "关键词长度不能超过100个字符")
    private String keyword;

    @Schema(description = "排序字段：create_time-创建时间，total_amount-订单金额，paid_amount-实付金额")
    @Pattern(regexp = "^(create_time|total_amount|paid_amount)$", message = "排序字段不正确")
    private String sortField;

    @Schema(description = "排序方向：ASC-升序，DESC-降序")
    @Pattern(regexp = "^(ASC|DESC)$", message = "排序方向不正确")
    private String sortOrder;

    @Schema(description = "是否包含订单明细：0-不包含，1-包含")
    private Integer includeItems;

    @Schema(description = "是否只查询已删除：0-未删除，1-已删除")
    private Integer isDeleted;
}